package org.chainsale.bean;

import java.util.List;

import javax.swing.JLabel;
import javax.swing.JTextField;


public class ActiveItem {

	private static final ActiveItem item = new ActiveItem();
	
	private Practitioner activePrac = null;
	private int activeId;
	
	private List<JLabel> propLabels;
	private JTextField addedNumText;
	private JTextField addedNameText;
	
	private JLabel totalPractionerText;
	private JLabel totalOutgoingText;
	private JLabel totalIncomingText;
	private JLabel inOutPercentText;
	
	private ActiveItem() { }
	
	public static ActiveItem getInstance() {
		return item;
	}
	
	public void addSystemPanel(JLabel totalPractionerText, JLabel totalOutgoingText, JLabel totalIncomingText, JLabel inOutPercentText) {
		setTotalPractionerText(totalPractionerText);
		setTotalOutgoingText(totalOutgoingText);
		setTotalIncomingText(totalIncomingText);
		setInOutPercentText(inOutPercentText);
	}
	
	public void changeSystemInfo() {
		totalPractionerText.setText("" + Practitioner.SYSTEM_TOTAL_NUMBER);
		totalOutgoingText.setText("" + Practitioner.SYSTEM_TOTAL_OUTGOING);
		totalIncomingText.setText("" + Practitioner.SYSTEM_TOTAL_INCOMING);
		double per = ((double) Practitioner.SYSTEM_TOTAL_INCOMING) /  ((double) Practitioner.SYSTEM_TOTAL_OUTGOING);
		String xPer = String.valueOf(per);
		if (xPer.length() > 7) {
			xPer = xPer.substring(0, 8);
		}
		inOutPercentText.setText(xPer);
	}
	
	public void changeNodeProperties() {
		propLabels.get(0).setText(activePrac.getName());
		propLabels.get(1).setText("" + activePrac.getShare());
		propLabels.get(2).setText("" + activePrac.getOutgoing());
		propLabels.get(3).setText("" + activePrac.getIncoming());
		propLabels.get(4).setText(activePrac.getRank().getName());
		propLabels.get(5).setText(activePrac.getSuperior() != null ? activePrac.getSuperior().getName() : "");
	}

	public Practitioner getActivePrac() {
		return activePrac;
	}

	public void setActivePrac(Practitioner activePrac) {
		this.activePrac = activePrac;
	}

	public int getActiveId() {
		return activeId;
	}

	public void setActiveId(int activeId) {
		this.activeId = activeId;
	}

	public List<JLabel> getPropLabels() {
		return propLabels;
	}

	public void setPropLabels(List<JLabel> propLabels) {
		this.propLabels = propLabels;
	}

	public JTextField getAddedNumText() {
		return addedNumText;
	}

	public void setAddedNumText(JTextField addedNumText) {
		this.addedNumText = addedNumText;
	}

	public JTextField getAddedNameText() {
		return addedNameText;
	}

	public void setAddedNameText(JTextField addedNameText) {
		this.addedNameText = addedNameText;
	}

	public JLabel getTotalPractionerText() {
		return totalPractionerText;
	}

	public void setTotalPractionerText(JLabel totalPractionerText) {
		this.totalPractionerText = totalPractionerText;
	}

	public JLabel getTotalOutgoingText() {
		return totalOutgoingText;
	}

	public void setTotalOutgoingText(JLabel totalOutgoingText) {
		this.totalOutgoingText = totalOutgoingText;
	}

	public JLabel getTotalIncomingText() {
		return totalIncomingText;
	}

	public void setTotalIncomingText(JLabel totalIncomingText) {
		this.totalIncomingText = totalIncomingText;
	}

	public JLabel getInOutPercentText() {
		return inOutPercentText;
	}

	public void setInOutPercentText(JLabel inOutPercentText) {
		this.inOutPercentText = inOutPercentText;
	}

}
